from django.db import models

# Create your models here.
from mptt.fields import TreeForeignKey
from mptt.models import MPTTModel


class CustomCatagery(models.Model):
    category = models.CharField(verbose_name='客户类别', unique=True, max_length=255)

    def __str__(self):
        return self.category

    class Meta:
        verbose_name_plural = verbose_name = '客户类别'


class CustomLevel(models.Model):
    level = models.CharField(verbose_name='客户等级', unique=True, max_length=255)

    def __str__(self):
        return self.level

    class Meta:
        verbose_name_plural = verbose_name = '客户等级'


class SupplierCatagery(models.Model):
    category = models.CharField(verbose_name='供应商类别', unique=True, max_length=255)

    def __str__(self):
        return self.category

    class Meta:
        verbose_name_plural = verbose_name = '供应商类别'


class CommodityCatagery(MPTTModel):
    category = models.CharField(verbose_name='商品类别', unique=True, max_length=255)
    parent = TreeForeignKey(
        'self', verbose_name=u'上级分类',
        related_name='children', db_index=True,
        null=True, blank=True
    )

    def __str__(self):
        return self.category

    class Meta:
        verbose_name_plural = verbose_name = '商品类别'

    class MPTTMeta:
        order_insertion_by = ['category']

class OutComeCatagery(models.Model):
    category = models.CharField(verbose_name='支出类别', unique=True, max_length=255)

    def __str__(self):
        return self.category

    class Meta:
        verbose_name_plural = verbose_name = '支出类别'


class InComeCatagery(models.Model):
    category = models.CharField(verbose_name='收入类别', unique=True, max_length=255)

    def __str__(self):
        return self.category

    class Meta:
        verbose_name_plural = verbose_name = '收入类别'


class CountUnit(models.Model):
    unit = models.CharField(verbose_name='计量单位', unique=True, max_length=255)

    def __str__(self):
        return self.unit

    class Meta:
        verbose_name_plural = verbose_name = '计量单位'


class SettlementWay(models.Model):
    settlement = models.CharField(verbose_name='结算方式', unique=True, max_length=255)

    def __str__(self):
        return self.settlement

    class Meta:
        verbose_name_plural = verbose_name = '结算方式'
